package com.example.basic.core.result;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static <T>  com.example.basic.core.result.Result<?> genSuccessResult() {
        return new  com.example.basic.core.result.Result<T>()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T>  com.example.basic.core.result.Result<T> genSuccessResult(T data) {
        return new  com.example.basic.core.result.Result<T>(data)
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T>  com.example.basic.core.result.Result<?> genFailResult(String message) {
        return new  com.example.basic.core.result.Result<T>()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }
}
